﻿package idv.cjcat.fenofsm.events {
	use namespace ffsm;
	
	import flash.events.*;
	import idv.cjcat.fenofsm.*;
	
	public class TransitionEvent extends Event {
		/**
		 * The <code>INIT</code> event is dispatched right after the <code>State.EXIT</code> event.
		 */
		public static const INIT:String = "fsmTransitionInit";
		/**
		 * The <code>COMPLETE</code> event is dispatched right before the <code>State.ENTER</code> event.
		 */
		public static const COMPLETE:String = "fsmTransitionComplete";
		/**
		 * The <code>PROGRESS</code> event is dispatched repeatedly during the transition if a transition's delay time is greater than zero.
		 */
		public static const PROGRESS:String = "fsmTransitionProgress";
		
		private var _progress:Number;
		private var _transition:Transition;
		private var _fsm:FSMachine;
		
		public function TransitionEvent(type:String, transition:Transition, progress:Number = NaN) {
			super(type);
			this._transition = transition;
			this._fsm = transition.fsm;
			this._progress = progress;
		}
		
		/**
		 * The associated transition.
		 */
		public function get transition():Transition { return _transition; }
		/**
		 * The associated finite state machine.
		 */
		public function get fsm():FSMachine { return _fsm; }
		/**
		 * The delayed transition progres. NaN if the transition delay is zero or negative.
		 */
		public function get progress():Number { return _progress; }
	}
}